home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / tcega.arc / GPAMTGD.C < prev    next >
Text File  |  1986-02-12  |  2KB  |  70 lines

  1. gpamtgd(image,width,height,length)
  2.   unsigned char far *image;
  3.   unsigned int  width,height,length;
  4. {
  5.   extern unsigned int  gdvw_x1,gdvw_x2,gdvw_x3;
  6.   extern unsigned int  gdvw_y1,gdvw_y2,gdvw_y3;
  7.   extern unsigned int  Dither4[4][4];
  8.  
  9.   unsigned char xscale[640];
  10.   unsigned char yscale[350];
  11.   unsigned char row[640];
  12.  
  13.   int  w,h,x,y,c;
  14.  
  15.   int  xi,xc,xs,yi,yc,ys;
  16.  
  17.   gpcolor(0);
  18.   gpmove(gdvw_x1,gdvw_y1);
  19.   gpbox(gdvw_x2,gdvw_y2);
  20.  
  21.   /* The dimension to our idea image is width x height.  Determine the largest
  22.      possible real image dimension for the current viewport. */
  23.  
  24.   if (((long)gdvw_y3 * (long)width * 4L) / (height * 3) <= gdvw_x3)
  25.     {
  26.     w = ((long)gdvw_y3 * (long)width * 4L) / (height * 3);
  27.     h = gdvw_y3;
  28.     }
  29.   else
  30.     {
  31.     w = gdvw_x3;
  32.     h = ((long)height * (long)gdvw_x3 * 3L) / (width * 4);
  33.     };
  34.  
  35.   /* Generate X and Y scale tables */
  36.  
  37.   gpslope(xscale,width,w);
  38.   gpslope(yscale,height,h);
  39.  
  40.   y = 0;
  41.   for (ys = 0; ys < height; ys++)
  42.     {
  43.     if ((yc = yscale[ys]) != 0)
  44.       {
  45.       while (yc--)
  46.         {
  47.         x  = 0;
  48.         xi = ys * length;
  49.         for (xs = 0; xs < width; xs++, xi++)
  50.           {
  51.           if ((xc = xscale[xs]) != 0)
  52.             {
  53.             while (xc--)
  54.               {
  55.               c = image[xi];
  56.               row[x++] = c / 16 + ( c % 16 > Dither4[y % 4][x % 4]) + 8;
  57.            /* row[x++] = c / 13 + 8; */
  58.               }
  59.             }
  60.           }
  61.         gpmove(gdvw_x1,gdvw_y1+y);
  62.         gpwtrow(row,w);
  63.         y++;
  64.         }
  65.       }
  66.  
  67.     }
  68.  
  69. }
  70.